﻿@model IEnumerable<tDonkeySite.Models.Course>
@{
    ViewBag.Title = "Courses";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
            </hgroup>
            <p>
                Search for courses by the following catagories:
            </p>
        </div>
    </section>
}

@using (Html.BeginForm()){    
         <p>
             <table>
             <tr><td>Course Number:</td><td>@Html.TextBox("number", "", new { }) </td></tr>
             <tr><td>Course Name:</td><td>@Html.TextBox("name", "", new { }) </td></tr>
             <tr><td>Teacher Name:</td><td>@Html.TextBox("teacherFirstName", "", new { }) </td></tr>
             <tr><td>Course Points:</td><td>@Html.TextBox("points", "", new { }) </td></tr>
               <tr><td>Exam Date:</td>
                 <td>
                     <!--Used this way to show the date textbox in order to try something -->
                     <input type="text" id="examDate" name="examDate" />
                 </td>
                 <td>Term: @Html.DropDownList("term", new SelectList(new object[]{ "A", "B" }))</td>
             </tr>
<tr><td>Start Time (format: HH.MM):</td><td>@Html.TextBox("startTime", "", new { }) </td></tr>
             <tr><td>End Time (format: HH.MM):</td><td>@Html.TextBox("endTime", "", new { }) </td></tr>
             <tr><td>Day (options א,ב,ג,ד,ה,ו):</td><td>@Html.TextBox("day", "", new { }) </td></tr>
               
              <tr><td>Faculty <a href="javascript:void(0)" id="flink" onclick="loadFaculties();">>></a>
                      </td><td rowspan="2"> <img id="wait" style="display:none;" src ="../../Images/wait.gif" />
                      <div id="flist" dir="rtl"></div><br /></td></tr>
             </table>
            <br />
            @Html.CheckBox("sameWord", false) Same Word
            &nbsp | &nbsp Num of results in page: <select name="count">
                                                    <option selected>25</option>
                                                    <option>50</option>
                                                    <option>100</option>
                                                    <option>150</option>
                                                    <option>250</option>
                                                  </select>
             &nbsp | &nbsp @Html.ActionLink("My Courses", "Select", "Courses")<br /><br />
             <input type="submit" value="Search" />
         </p>
} 



@if (ViewBag.Courses==null)
{
    <h5>@ViewBag.Message</h5>
    return;
}
<table>
    <tr>
        <th>
           Number
        </th>
        <th>
            Name
        </th>
        <th>
            Points
        </th>
        <th>
            Teacher
        </th>
    </tr>
    @foreach (eDonkeyClassLibrary.Course c in ViewBag.Courses)
    {
        <tr>
            <td>
                <a href=@("/Courses/Info/?number=" + c.Number)>@c.Number</a>
            </td>
            <td>
                @c.Name
            </td>
            <td>
                @c.Points
            </td>
            <td>
                @if (c.Teacher != null)
                {
                    @(c.Teacher.FirstName + " " + c.Teacher.LastName);
                }
            </td>
            <td>
               <form>
                <input id=@("selectButton" + c.Number) type="button" onclick="selectCourse('@c.Number', '@c.Name.Replace("'","\\'")', '@("selectButton" + c.Number)', @c.Points)" value="Select" />
               </form>
            </td>
            @if (User.Identity.Name == "Administrator")
            {
              <td>
              <input id=@("selectButton" + c.Number) type="button" onclick="cachCourse('@c.Number')" value="Cache" />
              </td>   
            }
        </tr>
    }
</table>


